/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

import java.util.Map;

/**
 * <p>This is a subclass of XREEvent that represents the "onFlash" event. It defines some properties specific to this
 * event. Note that values of all custom properties are actually stored in the XREEvent#params map.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
public class XREFlashEvent extends XREResourceEvent {

    /**
     * <p>Represents the name of the "on flash" event.</p>
     *
     * <p>This is a string constant used by the user when setting the name of the event.</p>
     */
    public static final String ON_FLASH_EVENT_NAME = "onFlashEvent";

    /**
     * <p>Represents the name used to retrieve the event type parameter.</p>
     */
    private static final String EVENT_TYPE = "eventType";

    /**
     * <p>Represents the name used to retrieve the data parameter.</p>
     */
    private static final String DATA = "data";

    /**
     * <p>Creates new instance of {@link XREFlashEvent} class.</p>
     */
    public XREFlashEvent() {
        // empty constructor
    }

    /**
     * <p>Retrieves the type of the shared event that was dispatched.</p>
     *
     * @return the type of the shared event that was dispatched
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public String getEventType() {
        return getTypedParam(EVENT_TYPE, String.class);
    }

    /**
     * <p>Sets the type of the shared event that was dispatched.</p>
     *
     * @param eventType the type of the shared event that was dispatched
     *
     * @throws IllegalStateException if params is null
     */
    public void setEventType(String eventType) {
        setParam(EVENT_TYPE, eventType);
    }

    /**
     * <p>Retrieves the map with data associated with the event.</p>
     *
     * @return the map with data associated with the event
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    @SuppressWarnings("unchecked")
    public Map<String, Object> getData() {
        return getTypedParam(DATA, Map.class);
    }

    /**
     * <p>Sets the map with data associated with the event.</p>
     *
     * @param data the map with data associated with the event
     *
     * @throws IllegalStateException if params is null
     */
    public void setData(Map<String, Object> data) {
        setParam(DATA, data);
    }
}

